import math
import random

'''from 得分函数测试 import getZeroRandomIVq_ROF, getequalallnozerorcase, getL1eqL3L2eqL4case, getL1eqL3L2noeqL4case, \
    getL1bigerL3L2eqL4case, getL1randomL2L3eqL4Case
from  得分函数测试 import getL1bigerL3L2bigerL4case, getL1bigerL3L2litterL4case, li_data, RandomCase, getstopRandomCase, \
    getStopEndRandomCase,getL1eqlL2L3eqL4Case,getL1eqlL2L3eqL4Case_1'''


import math as m
from scipy.stats import beta
import numpy as np

a1 = [[([0.7, 0.8], [0.2, 0.3]), ([0.5, 0.6], [0.6, 0.7]), ([0.8, 0.9], [0.1, 0.2]), ([0.8, 0.95], [0.1, 0.2])],
      [([0.8, 0.9], [0.1, 0.2]), ([0.5, 0.55], [0.4, 0.5]), ([0.8, 0.9], [0.1, 0.15]), ([0.8, 0.95], [0.1, 0.2])],
      [([0.9, 0.95], [0.1, 0.2]), ([0.5, 0.6], [0.3, 0.4]), ([0.8, 0.85], [0.2, 0.3]), ([0.8, 0.9], [0.1, 0.2])],
      [([0.2, 0.3], [0.7, 0.8]), ([0.4, 0.5], [0.3, 0.4]), ([0.75, 0.8], [0.2, 0.3]), ([0.7, 0.8], [0.2, 0.3])],
      [([0.1, 0.2], [0.8, 0.9]), ([0.2, 0.3], [0.5, 0.6]), ([0.7, 0.85], [0.3, 0.4]), ([0.6, 0.7], [0.2, 0.3])]]


# alpha = get_Beta_random_number(loc=5, scale=1, N=50)
# beta = get_Beta_random_number(loc=5, scale=1, N=50)


def f0(IVq_ROF, q):
    '''
    :param IVq_ROF: 广义正交数
    :param q:
     :return:
    '''
    a = IVq_ROF[0][0] ** q
    b = IVq_ROF[0][1] ** q
    c = IVq_ROF[1][0] ** q
    d = IVq_ROF[1][1] ** q
    score = ((abs(a - c) ** (1 / q) + abs(b - d) ** (1 / q)) / 2) + 1
    # Accaurate=(b-a)**(1/q)+(d-c)**(1/q)
    return (score / 2)


def f1(IVq_ROF, q):
    '''

    :param IVq_ROF: 广义正交数
    :param q:
    :return:
    '''
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    score = ((a + b) * (a + c) - (c + d) * (b + d)) / 2
    return score


def f2(IVq_ROF, q):
    '''

    :param IVq_ROF: 广义正交数
    :param q:
    :return:
    '''
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    score = a + b * (1 - a - c) + b + a * (1 - b - d)
    return score


def f3(IVq_ROF, q):
    a = IVq_ROF[0][0] ** q
    b = IVq_ROF[0][1] ** q
    c = IVq_ROF[1][0] ** q
    d = IVq_ROF[1][1] ** q
    score = (a - c) * ((1 - a - c) ** (1 / q)) + (b - d) * ((1 - b - d) ** (1 / q)) + abs(a - c) + abs(b - d)
    return score / 2


def f4(IVq_ROF, q):
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    score = (1 / 2) * (a ** q + b ** q - c ** q - d ** q)
    return (score + 1) / 2


def f5(IVq_ROF, q):
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    score = a - c + b - d + (1 - a - c ** q) ** (1 / q) + (1 - b ** q - d ** q) ** (1 / q)

    print((score) / 2)
    return (score) / 2


def f6(IVq_ROF, q):
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    pai1 = (1 - a ** q - c ** q) ** (1 / q)
    pai2 = (1 - b ** q - d ** q) ** (1 / q)
    score = a + b + c + d + m.cos((b - a) * (m.pi / 2)) + m.cos((d - c) * (m.pi / 2)) + m.sin(
        (a - c) * (m.pi / 2)) + m.sin((b - d) * (m.pi / 2))
    score = (score - 2) / 4

    return score


'''f7==f6'''


def f7(IVq_ROF, q):
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    if a == 0:
        pai1 = (1 - 0 - c ** q) ** (1 / q)
        pai2 = (1 - b ** q - d ** q) ** (1 / q)
    if b == 0:
        pai1 = (1 - a ** q - c ** q) ** (1 / q)
        pai2 = (1 - 0 - d ** q) ** (1 / q)
    if c == 0:
        pai1 = (1 - a ** q - 0) ** (1 / q)
        pai2 = (1 - b ** q - 0) ** (1 / q)
    if d == 0:
        pai1 = (1 - a ** q - 0) ** (1 / q)
        pai2 = (1 - b ** q - 0) ** (1 / q)

    if c != 0 and a != 0 and b != 0 and d != 0:
        pai1 = (1 - a ** q - c ** q) ** (1 / q)
        pai2 = (1 - b ** q - d ** q) ** (1 / q)
    score = ((a + b + c + d) + (pai1 + pai2)) + 4 * (
                m.cos((b + c - a - d) * (m.pi / 4)) * m.cos((d - a + 1) * (m.pi / 4)) * m.cos((c - b + 1) * (m.pi / 4)))
    # score=round(score,5)
    return (score - 4) / 4

def qTest1(IVq_ROF,q):
    '''
    1、广义正交模糊集的得分函数（2020） 只有u和v
    :param q_ROFs:
    :param q:
    :return:
    '''
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    pai = (1 - a**q - c**q)**(1/q)
    score = (math.e**(a**q-c**q))/(1+pai**q)
    return score

def qTest2(IVq_ROF,q):
    '''
    1、广义正交模糊集的得分函数（2020）第2种 只有u和v
    :param q_ROFs:
    :param q:
    :return:
    '''
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    pai = (1 - a**q - c**q)**(1/q)
    temp = (math.e**(a**q-c**q))/(math.e**(a**q-c**q)+1)
    score = a**q-c**q+(temp-1/2)*(pai**q)
    return score

def test2(IVq_ROF,q):
    '''
    2、区间值直觉模糊集的度量方法（王中兴 ，牛利利，2013年）
    :param IVq_ROF:
    :param q:
    :return:
    '''
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    score = 1.0/2*(a**q+b**q-c**q-d**q)
    return score

def test3(IVq_ROF,q):
    '''
    3、区间值直觉模糊集的度量方法（王 中兴 ，牛利利，2013年）
    :param IVq_ROF:
    :param q:
    :return:
    '''
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    M_u = (a+b)/2.0
    M_v = (c+d)/2.0
    M_π = ((1-b-d)+(1-a-c))/2.0
    score = (M_u - M_v)*(1+M_π)
    return score

def test4(IVq_ROF,q):
    '''
    4、徐泽水提出的区间值得分函数（2007）
    :param IVq_ROF:
    :param q:
    :return:
    '''
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    score = (a-c+b-d/2)+1
    return score

def test5(IVq_ROF,q):
    '''
    5、Chen提出的基于集合对分析理论的得分函数（2021）
    :param IVq_ROF:
    :param q:
    :return:
    '''
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    if(a!=c):
        score =(a-c)*(1-b)
    else:
        score = a*(1+b)
    return score

def test6(IVq_ROF,q):
    '''
    6、Chen S.M提出的得分函数（2017）
    :param IVq_ROF:
    :param q:
    :return:
    '''
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    score = (a+b+math.sqrt(b*d)*(1-a-c)+math.sqrt(a*c)*(1-b-d))/2
    return score

def test7(IVq_ROF,q):
    '''
    7、Chen S.M提出的区间值得分函数（2021）
    :param IVq_ROF:
    :param q:
    :return:
    '''
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    temp = random.randint(0,1000000)
    if 0<= b+d <=1:
        temp = math.sqrt(a) + math.sqrt(b) + math.sqrt(1 - c) + math.sqrt(1 - d)
    score = temp / 2
    return score

def test8(IVq_ROF,q):
    '''
     8:Chen提出的基于Sin、Beta分布的得分函数（2021）
    :param IVq_ROF:
    :param q:
    :return:
    '''
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    sF_g = (a - c + b - d) / 2 + 1
    sin1 = math.sin(E_T(a,b) * math.pi / 2)
    sin2 = math.sin(E_T(b,1-d) * math.pi / 2)
    sin3 = math.sin(E_T(1-d,1-c) * math.pi / 2)
    score = sF_g + sin1 + sin2 + sin3
    return score

def test9(IVq_ROF,q):
    '''
    9:Sengupta, T.K. Pal提出的得分函数（2000年）
    :param IVq_ROF:
    :param q:
    :return:
    '''
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    # if(a==c):
    #     score=1
    # elif(a>=c>=a+d):
    temp = random.randint(0,1000000)
    if((a-(a+c))!=0):
        temp = (c-(a+d))/(a-(a+c))
    score = max(0,temp)
    return score

def test10(IVq_ROF,q):
    '''
    10:J.A.G. Campos,提出的Beta分布得分函数
    :param IVq_ROF:
    :param q:
    :return:
    '''
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    aerfa = 2
    beita = 3
    score = a + (b - a) * (aerfa / (aerfa + beita))
    return score

def test11(IVq_ROF,q):
    '''
    11.Cheng’s得分函数(2018)
    :param IVq_ROF:
    :param q:
    :return:
    '''
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    score = (a - c + b - d) / 2 + 1
    return score

def test12(IVq_ROF,q):
    '''
    12.ZY. Bai提出的区间值得分函数(2013)
    :param IVq_ROF:
    :param q:
    :return:
    '''
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    temp = a + b + a * (1 - a - c )+ b * (1 - b - d)
    score = temp / 2
    return score

def test13(IVq_ROF,q):
    '''
    13.Zhi-yong Bai 提出的得分函数（2013）
    14、基于trigonometric function的得分函数 少了关系式
    :param IVq_ROF:
    :param q:
    :return:
    '''
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    temp = a + a * (1 - a - c) + b + b * (1 - b - d)
    score = temp / 2
    return score

def test14(IVq_ROF,q):
    '''
    14:基于trigonometric function的得分函数
    :param IVq_ROF:
    :param q:
    :return:
    '''
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    S_A = ((a-c+b-d)/2+1)/2
    E_A = b-a+d-c
    H_A = a+1-b+c+1-d
    temp1 = (math.sin(S_A)/math.sin(1))
    temp2 = (math.sin(H_A)/math.sin(1))
    temp3 = (math.cos(E_A)-math.cos(1))/(1-math.cos(1))
    score = (temp1*temp2*temp3)**(1/3)
    return score

def test15(IVq_ROF,q):
    '''
    15、Minkowski Weighted Score Functions of Intuitionistic Fuzzy Values (2020)
    :param IVq_ROF:
    :param q:
    :return:
    '''
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    p = 2
    tA = random.uniform(a,b)
    fA = random.uniform(c,d)
    score = ((tA ** p + (1 - fA) ** p) / 2 ) ** (1 / p)
    return score

def test16(IVq_ROF,q):
    '''
    16:Gong and Ma’s score function of the IVIFS（2019）
    :param IVq_ROF:
    :param q:
    :return:
    '''
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    add1 = (d + c - b - a) / 2
    if(a+b+c+d!=0):
        add2 = (a + b + 2 * (a * b - c * d)) / (a + b + c + d)
    score = add1 + add2
    return score

def test17(IVq_ROF,q):
    '''
    17、Wang and Chen’s score function of the IVIFS（2018）
    :param IVq_ROF:
    :param q:
    :return:
    '''
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    score = ((a+b)*(a+c) - (c+d)*(b+d)) / 2
    return score

def test18(IVq_ROF,q):
    '''
    18、Sahin’s accuracy function of the IVIFS（2016）
    :param IVq_ROF:
    :param q:
    :return:
    '''
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    score = (a+b*(1-a-c)+b+a*(1-b-d))/2
    return score

def test19(IVq_ROF,q):
    '''
    19、Gao et al.’s score function of the IVIFS（2016）
    :param IVq_ROF:
    :param q:
    :return:
    '''
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    score = random.randint(0,1000000)
    if((a+b-a*c+b*d)!=0):
        score = 1/4*(a-c+b-d)*(1+1/(a+b-a*c+b*d))
    return score

def test20(IVq_ROF,q):
    '''
    20、Zhang and Xu’s accuracy function of the IVIFS
    :param IVq_ROF:
    :param q:
    :return:
    '''
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    add1 = ((a-c)+(b-d)*(1-a-c))/2
    add2 = ((b-d)+(a-c)*(1-b-d))/2
    score = (add1+add2)/2
    return score

def test21(IVq_ROF,q):
    '''
    21、彭新东提出的Information-based Score function（2020）
    :param IVq_ROF:
    :param q:
    :return:
    '''
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    add1 = 1+a+b-c-d+0.5*(math.fabs(a-c)+math.fabs(b-d))
    add2 = (1+a+c)*(math.e**(a-c+a+b))/(math.e**3)+(1+b+d)*(math.e**(b-d-c-d))/math.e
    add3 = (2-c-d)/(4-a-b-c-d)
    score = add1 * add2 * add3 /16
    return score

def test22(IVq_ROF,q):
    '''
    22、精确函数
    :param IVq_ROF:
    :param q:
    :return:
    '''
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    score = a+b-1+(c+d)/2
    return score

def test23(IVq_ROF,q):
    '''
    23、直觉的得分函数  需要a1=b1 c1=d1
    :param IFS: u,v
    :param q:
    :return:
    '''
    a1 = IVq_ROF[0][0][0]
    #b1 = IVq_ROF[0][0][1]
    c1 = IVq_ROF[0][1][0]
    #d1 = IVq_ROF[0][1][1]
    pai1 = 1-a1-c1

    a2 = IVq_ROF[1][0][0]
    #b2 = IVq_ROF[1][0][1]
    c2 = IVq_ROF[1][1][0]
    #d2 = IVq_ROF[1][1][1]
    pai2 = 1- a2 -c2

    x_avg = (a1-c1+a2-c2)/2
    y_avg = (a1+c1+a2+c2)/2

    if(a1-c1>=x_avg):
        v1_A_1 = (a1-c1-x_avg)**0.88
    else:
        v1_A_1 = -2.25*((x_avg-a1+c1)**0.88)

    if(a2-c2>=x_avg):
        v1_A_2 = (a2-c2-x_avg)**0.88
    else:
        v1_A_2 = -2.25*((x_avg-a2+c2)**0.88)

    if(a1-c1>=y_avg):
        v2_A_1 = (a1+c1-y_avg)**0.88
    else:
        v2_A_1 = -2.25*((y_avg-a1-c1)**0.88)

    if (a2 - c2 >= y_avg):
        v2_A_2 = (a2 + c2 - y_avg) ** 0.88
    else:
        v2_A_2 = -2.25 * ((y_avg - a2 - c2) ** 0.88)

    score1 = a1-c1+(a1-c1+v1_A_1+v2_A_1)*pai1
    score2 = a2-c2+(a2-c2+v1_A_2+v2_A_2)*pai2
    if(score1==score2):
        return 0
    else:
        return 1

    # a = IFS[0][0]
    # c = IFS[1][0]
    # x = a-c
    # y = a+c
    # v1_A = (a-c-x)**0.88
    # v2_A = (a+c-y)**0.88
    # score = a-c+(a-c+v1_A+v2_A)*math.pi
    # return score

def test24(IVq_ROF,q):
    '''
    24、可能度得分（2016、2013等进行不同改进）
    :param IVq_ROF:
    :param q:
    :return:
    '''
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    temp = (d-a)/(c-a+d-b)
    score = max(1-max(temp,0),0)
    return score


def test25(IVq_ROF,q):
    '''
    25、prospect score functio（2012）
    :param IVq_ROF:
    :param q:
    :return:
    '''
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    e = (1-a**q-c**q)**(1/q)
    f = (1-b**q-d**q)**(1/q)
    aerfa = 0.88
    mi_u = a+b
    ni_u = b-a
    mi_v = c+d
    ni_v = d-c
    x = (mi_u*(1-ni_u)-mi_v*(1-ni_v))/(2-ni_u-ni_v)
    y = (mi_u*(1-ni_u)-mi_v*(1-ni_v))/(2-ni_u-ni_v)
    v1_A = (((mi_u*(1-ni_u)-mi_v*(1-ni_v))/(2-ni_u-ni_v))-x)**aerfa
    v2_A = (((mi_u * (1 - ni_u) - mi_v * (1 - ni_v)) / (2 - ni_u - ni_v)) - x) ** aerfa
    score = a-c+b-d +(a-c+b-d+v1_A+v2_A*(f-e))
    return score

def test26(IFS,q):
    '''
    26、knowledge measure，Entropy（2020）
    :param IVq_ROF:
    :param q:
    :return:
    '''
    # a=u c=v
    a = IFS[0][0]
    c = IFS[1][0]
    p = 1
    KF_A = 1/(2**(1/p)+1)*((a**p+c**p+(a+c)**p)**(1/p)+math.fabs(a**p-c**p)**(1/p))
    C = 500
    SF_A = (math.e**(C*(a-c))-1)/(math.e**(C*(a-c))+1)*KF_A
    score = SF_A
    return score

def test26_2(IVq_ROF,q):
    '''
    26、knowledge measure，Entropy（2020）
    :param IVq_ROF:
    :param q:
    :return:
    '''
    # a=u c=v
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    p = 1
    sum1 = (a**p + b**p + c**p + d**p)/2
    sum2 = ((a+c)**p+(b+d)**p)/2
    sum3 = (b**p-d**p+a**p-c**p)/2
    KF_A = 1/(2**(1/p)+1)*((sum1+sum2)**(1/p)+math.fabs(sum3)**(1/p))
    C = 500
    SF_A = (math.e**(C*(b-d+a-c)/2)-1)/(math.e**(C*(b-d+a-c)/2)+1)*KF_A
    score = SF_A
    return score

def test27(IVq_ROF,q):
    '''
    27、a better score function
    :param IVq_ROF:
    :param q:
    :return:
    '''
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    sum = a + b +(1-math.sqrt(c))**2+(1-math.sqrt(d))**2
    divide = 6-math.sqrt(c)-math.sqrt(d)-math.sqrt(a)-math.sqrt(b)
    score = sum/divide
    return score

def test28(IVq_ROF,q):
    '''
    28、Dü˘genci’s Distance Measure-Based Method（2014）
    :param IVq_ROF:
    :param q:
    :return:
    '''
    a1 = IVq_ROF[0][0][0]
    b1 = IVq_ROF[0][0][1]
    c1 = IVq_ROF[0][1][0]
    d1 = IVq_ROF[0][1][1]

    a2 = IVq_ROF[1][0][0]
    b2 = IVq_ROF[1][0][1]
    c2 = IVq_ROF[1][1][0]
    d2 = IVq_ROF[1][1][1]

    t,p=2,1
    sum1 = (math.fabs(t*(a1-a2)-(c1-c2)))**p
    sum2 = (math.fabs(t*(c1-c2)-(a1-a2)))**p
    sum3 = (math.fabs(t*(b1-b2)-(d1-d2)))**p
    sum4 = (math.fabs(t*(d1-d2)-(b1-b2)))**p
    temp = 1/4/((1+t)**p)
    score = temp*((sum1+sum2+sum3+sum4)**(1/p))
    return score

    # a = IVq_ROF[0][0]
    # b = IVq_ROF[0][1]
    # c = IVq_ROF[1][0]
    # d = IVq_ROF[1][1]
    #
    # a2 = IVq_ROF[2][0]
    # b2 = IVq_ROF[2][1]
    # c2 = IVq_ROF[3][0]
    # d2 = IVq_ROF[3][1]
    # print("C2,D2")
    # print(c2,d2)
    # t = 2
    # p = 1
    # temp1 = 1/4/((1+t)**p)
    # sum1 = math.fabs(t*(a-b)-(c-d))
    # sum2 = math.fabs(t*(c-d)-(a-b))
    # sum3 = math.fabs(t*(a-b)-(c-d))
    # sum4 = math.fabs(t*(c-d)-(a-b))
    # score = temp1*((sum1**p+sum2**p+sum3**p+sum4**p))**(1/p)
    # return score



def test29(IVq_ROF,q):
    '''
    29、Zhang et al.’s [13] Entropy Measures for IvIFSs:
    :param IVq_ROF:
    :param q:
    :return:
    '''
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    temp1 = (a-c)
    temp2 = (b-d)
    if(max(temp1,temp2)<0):
        score = random.randint(1,100000)
    else:
        score = 1/2*(1-math.sqrt(max(temp1,temp2)))
    return score

def test30(IVq_ROF,q):
    '''
    30、N. Thillaigovindan, S. Anita Shanthi, J. Vadivel Naidu（2016）
    :param IVq_ROF:
    :param q:
    :return:
    '''
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    sum = a +b+(1-math.sqrt(c))**2+(1-math.sqrt(d))**2
    pai_fu = (1-math.sqrt(a)-math.sqrt(c))**2
    pai_zheng = (1-math.sqrt(b)-math.sqrt(d))**2
    divide = 4+math.sqrt(pai_fu)+math.sqrt(pai_zheng)
    score = sum/divide
    return score

def test31(IVq_ROF,q):
    '''
    31、Ye（2009）
    :param IVq_ROF:
    :param q:
    :return:
    '''
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    e = (1 - a ** q - c ** q) ** (1 / q)
    f = (1 - b ** q - d ** q) ** (1 / q)
    score = (a-e+b-f)/2
    return score

def test32(IVq_ROF,q):
    '''
    32、Nayagam(2011)
    :param IVq_ROF:
    :param q:
    :return:
    '''
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    score = ((a-d*(1-b))+b-c*(1-a))/2
    return score

def test33(IVq_ROF,q):
    '''
    33、Gao and Liu (2015)
    :param IVq_ROF:
    :param q:
    :return:
    '''
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    e = (1 - a ** q - c ** q) ** (1 / q)
    f = (1 - b ** q - d ** q) ** (1 / q)
    score = (a+b-c-d+2)/(e+f+4)
    return score

def test34(IVq_ROF,q):
    '''
    34、Sabin(2015)
    :param IVq_ROF:
    :param q:
    :return:
    '''
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    e = (1 - a ** q - c ** q) ** (1 / q)
    f = (1 - b ** q - d ** q) ** (1 / q)
    score = (a+b*e+b+a*f)/2
    return score

def test35_a(IVq_ROF,q):
    '''
    a:Ye,2010
    :param IVq_ROF:
    :param q:
    :return:
    '''
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    score = (1/(math.sqrt(2)-1))*(math.sqrt(2)*math.cos((a+b-c-d)/8)*math.pi-1)
    return score

def test35_b(IVq_ROF,q):
    '''
    b:Zhang et al,2010
    :param IVq_ROF:
    :param q:
    :return:
    '''
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    up = min(a,c)+min(b,d)
    divided = max(a,c)+max(b,d)
    score = up/divided
    return score

def test35_c(IVq_ROF,q):
    '''
    c:wei et al,2011
    :param IVq_ROF:
    :param q:
    :return:
    '''
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    e = (1 - a ** q - c ** q) ** (1 / q)
    f = (1 - b ** q - d ** q) ** (1 / q)
    up = min(a, c) + min(b, d)+e+f
    divided = max(a, c) + max(b, d)+e+f
    score = up/divided
    return score

def test35_d(IVq_ROF,q):
    '''
    d:zhang at al,2011
    :param IVq_ROF:
    :param q:
    :return:
    '''
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    t =0.5
    Ma = a + t*(b-a)
    Na = c + t*(d-c)
    score = (1-Ma+Na)*(math.e**(1-Ma+Na))
    return score

def test35_e(IVq_ROF,q):
    '''
    e:Sun and Liu,2012
    :param IVq_ROF:
    :param q:
    :return:
    '''
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    e = (1 - a ** q - c ** q) ** (1 / q)
    f = (1 - b ** q - d ** q) ** (1 / q)
    up =math.fabs(a-c)+math.fabs(b-d)
    divided = 2+f+e+min(a+b,c+d)
    score = 1-up/divided
    return score

def test35_f(IVq_ROF,q):
    '''
    f:Chen et al,2013
    :param IVq_ROF:
    :param q:
    :return:
    '''
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    up = math.fabs(a-c+b-d)
    divided = 4-a-c-b-d
    score = 1/math.tan(math.pi/4+up/4/divided*math.pi)
    return score

def test35_g(IVq_ROF,q):
    '''
    g:Jing,2013
    :param IVq_ROF:
    :param q:
    :return:
    '''
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    e = (1 - a ** q - c ** q) ** (1 / q)
    f = (1 - b ** q - d ** q) ** (1 / q)
    up = 2+e+f-math.fabs(a-c)-math.fabs(b-d)
    divided = 2+e+f
    score = up/divided
    return score

def test35_h(IVq_ROF,q):
    '''
    h:Zhang et al,2014
    :param IVq_ROF:
    :param q:
    :return:
    '''
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    score = 1-1/2*(math.fabs(b-0.5)+math.fabs(a-0.5)+math.fabs(d-0.5)+math.fabs(c-0.5))
    return score

def test35_i(IVq_ROF,q):
    '''
    i:Wei and Zhang,2015
    :param IVq_ROF:
    :param q:
    :return:
    '''
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    pai1 = (1 - a ** q - c ** q) ** (1 / q)
    pai2 = (1 - b ** q - d ** q) ** (1 / q)
    up = math.fabs(a-c)+math.fabs(b-d)
    divided = 2*(2+pai2+pai1)
    score = math.cos(up/divided*math.pi)
    return score

def test36(IVq_ROF,q):
    '''
    36、Hoang  Nguye(2015)
    :param IVq_ROF:
    :param q:
    :return:
    '''
    # a=b=u c=d=v
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    #score = 1/(2*math.sqrt(2))*math.sqrt(a**2+b**2+c**2+d**2+(a+b)**2+(c+d)**2)
    score = 1/math.sqrt(2)*math.sqrt(a**2+c**2+(a+c)**2)
    return score

def test37(IVq_ROF,q):
    '''
    37、Hoang Nguyen（2016）基于36个得分函数提出的（pass）
    :param IVq_ROF:
    :param q:
    :return:
    '''
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    score = 1-2*math.fabs(2*a-0.5)
    return score


def test38(IVq_ROF,q):
    '''
    38、YingJun Zhang（2011）
    :param IVq_ROF:
    :param q:
    :return:
    '''
    # a=b=u c=d=v
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    score = (1-a-c)*(math.e**(1-a-c))
    # score = 1-(a+d)*(math.e**1-(a+d))
    return score

def test39(IVq_ROF,q):
    '''
    39、Kaihong Guo（2018）
    :param IVq_ROF:
    :param q:
    :return:
    '''
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    e = (1 - a ** q - c ** q) ** (1 / q)
    f = (1 - b ** q - d ** q) ** (1 / q)
    score = 1 - 1/2*(1-math.fabs(a-c)/2+math.fabs(b-d))*(1+1/2*(e+f))
    return score

def test40(IVq_ROF,q):
    '''
    40、Liu [14] dealt with the abstention group influence
    :param IFS:
    :param q:
    :return:
    '''
    # a=b=u c=d=v
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    # score = a+a*(1-a-c)+c+c*(1-b-d)
    score = a+a*(1-a-c)
    return score

def test41(IVq_ROF,q):
    '''
    41、Liu and Wang（分解成n等分）
    :param IVq_ROF:
    :param q:
    :return:
    '''
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    # pai1 = (1 - a ** q - c ** q) ** (1 / q)
    # pai2 = (1 - b ** q - d ** q) ** (1 / q)
    # aerfa = 0.1
    # beita = 0.5
    # score = a+(aerfa/(aerfa+beita))*pai1+c+(aerfa/(aerfa+beita))*pai2
    pai = 1-a-c
    aerfa = 0.1
    beita = 0.1
    score = a+aerfa*pai/(aerfa+beita)
    return score

def test42(IVq_ROF,q):
    '''
    42、 Zhou and Wu [22] divided the abstention group
    :param IVq_ROF:
    :param q:
    :return:
    '''
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    # pai1 = (1 - a ** q - c ** q) ** (1 / q)
    # pai2 = (1 - b ** q - d ** q) ** (1 / q)
    # aerfa = 0.1
    # beita = 0.5
    # score = a-b+(aerfa-beita)*pai1+c-d+(aerfa-beita)*pai2
    pai = 1-a-c
    aerfa=0.1
    beita=0.5
    score = a-c+(aerfa-beita)*pai
    return score

def test43(IVq_ROF,q):
    '''
    43、Lin et al. [23] introduced a new method:
    :param IVq_ROF:
    :param q:
    :return:
    '''
    # a=b=u c=d=v
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    # score = 2*a+b-1+2*c+d-1
    score = 2*a+c-1
    return score

def test44(IVq_ROF,q):
    '''
    44、Lin et al. [16] introduced a new score function
    :param IVq_ROF:
    :param q:
    :return:
    '''
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    # a=b=u c=d=v
    pai = 1-a-c
    # pai1 = (1 - a ** q - c ** q) ** (1 / q)
    # pai2 = (1 - b ** q - d ** q) ** (1 / q)
    #score = 1/2*(a+c)+3/2*(1-pai1+1-pai2)-2
    score = a/2+3/2*(1-pai)-1
    return score

def test45(IVq_ROF,q):
    '''
    45、Ye [25] introduced an improved score function:
    :param IVq_ROF:
    :param q:
    :return:
    '''
    # a=b=u c=d=v
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    # score = a-c+b-d+a*(1-a-b)+c*(1-c-d)
    miu = 0.1   # 随机赋个值
    score = a-c+miu*(1-a-c)
    return score


def test46(IVq_ROF,q):
    '''
    46、, Ye [26] introduced another improved score function
    :param IVq_ROF:
    :param q:
    :return:
    '''
    # a=b=u c=d=v
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    pai = 1-a-c
    score = a*(1+pai)-pai**2
    return score


def test47(IVq_ROF,q):
    '''
    47、Wang and Li [18] introduced a new score function
    :param IVq_ROF:
    :param q:
    :return:
    '''
    pass

def test48(IVq_ROF,q):
    '''
    48、Prospect theory score function
    :param IVq_ROF:
    :param q:
    :return:
    '''
    # a=b=u  c=d=v
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    pai = 1-a-c
    x_avg = a-c
    y_avg = a+c
    aerfa = 1
    namuda = 1
    if(a-c>=x_avg):
        v1_A = (a-c-x_avg)**aerfa
    else:
        v1_A = -namuda*((x_avg-(a-c))**aerfa)

    if(a-c>=y_avg):
        v2_A = (a+c-y_avg)**aerfa
    else:
        v2_A = -namuda*((y_avg-(a+c))**aerfa)
    score = a-c+(a-c+v1_A+v2_A)*pai
    # x_avg = 1/2*(a-b+c-d)
    # y_avg = 1/2*(a+b+c+d)
    # aerfa = 1
    # k = 1
    # if(a-b>=x_avg):
    #     v1_A_1 = (a-b-x_avg)**aerfa
    # else:
    #     v1_A_1 = -k * ((x_avg - (a - b)) ** aerfa)
    # if(c-d>=x_avg):
    #     v1_A_2 = (c - d - x_avg) ** aerfa
    # else:
    #     v1_A_2 = -k * ((x_avg - (c - d)) ** aerfa)
    # if(a-b>=y_avg):
    #     v2_A_1 = (a+b-y_avg)**aerfa
    # else:
    #     v2_A_1 = -k * ((y_avg - (a + b)) * aerfa)
    # if (c-d >= y_avg):
    #     v2_A_2 = (c + d - y_avg) ** aerfa
    # else:
    #     v2_A_2 = -k * ((y_avg - (c + d)) * aerfa)
    # score = a-b+(a-b+v1_A_1+v2_A_1)*pai1+c-d+(c-d+v1_A_2+v2_A_2)*pai2
    return score

def test49(IVq_ROF,q):
    '''
    49、Wang(2006)
    :param IVq_ROF:
    :param q:
    :return:
    '''
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    # score = (3*a+3*b-c-d-1)/2
    score = (3*a-c-1)/2
    return score

def test50(IVq_ROF,q):
    '''
    50 Thillaigovindan
    :param IVq_ROF:
    :param q:
    :return:
    '''
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    sum = a+b+(1-math.sqrt(c))**2+(1-math.sqrt(d))**2
    divide = 6-math.sqrt(c)-math.sqrt(d)-math.sqrt(a)-math.sqrt(b)
    score = sum/divide
    return score

def test51(IVq_ROF,q):
    '''
    51、Dugenci’s  少了t和p
    :param IVq_ROF:
    :param q:
    :return:
    '''
    a1 = IVq_ROF[0][0][0]
    # b1 = IVq_ROF[0][0][1]
    c1 = IVq_ROF[0][1][0]
    # d1 = IVq_ROF[0][1][1]
    pai1 = 1 - a1 - c1

    a2 = IVq_ROF[1][0][0]
    # b2 = IVq_ROF[1][0][1]
    c2 = IVq_ROF[1][1][0]
    # d2 = IVq_ROF[1][1][1]
    pai2 = 1 - a2 - c2
    t,p=2,1

    score = ((0.5/((1+t)**p))*(math.fabs(t*(a1-a2)-c1-c2)**p+math.fabs(t*(c1-c2)-(a1-a2))**p))**(1/p)
    return score
    # a = IVq_ROF[0][0]
    # b = IVq_ROF[0][1]
    # c = IVq_ROF[1][0]
    # d = IVq_ROF[1][1]
    # t = 1
    # p = 1
    # score = ((0.5/((1+t)**p))*(math.fabs(t*(a-b)-c-d)**p+math.fabs(t*(c-d)-(a-b))**p))**(1/p)
    # return score

def getpoint(IVq_ROF, q):
    a = (IVq_ROF[0][0])
    b = (IVq_ROF[0][1])
    c = (IVq_ROF[1][0])
    d = (IVq_ROF[1][1])
    while(b**q+d**q>1):
        q=q+1
        if(b**q+d**q<=1):
            break
    e = (1-b**q-d**q)**(1/q)
    f = (1-a**q-c**q)**(1/q)
    k=51
    alpha = 0.88
    beta = 0.88
    theta = 2.25
    delta= 0.61
    gamma = 0.69
    p=1/k
    pi1 = (p ** gamma) / (p ** gamma + (1 - p) ** gamma) ** (1 / gamma)
    pi2 = (p ** delta) / (p ** delta + (1 - p) ** delta) ** (1 / delta)
    point_u= []
    point_v= []
    point_pi =[]
    step_u = (b - a) / (k - 1)
    step_v = (d - c) / (k - 1)
    step_pi=(f-e)/(k-1)
    for i in range(k):
        point_u.append(a + step_u * i)
        point_v.append(c + step_v * i)
        point_pi.append(e + step_pi * i)
    average = 0.5
    prospect_u= [0 for i in range(k)]  # 取中间值为参考点
    d_u = [0 for i in range(k)]
    for i in range(k):
        d_u[i] = point_u[i] - average
        if (d_u[i] >= 0):
            prospect_u[i] = (d_u[i] ** alpha)*pi1
        if (d_u[i] < 0):
            prospect_u[i] = -1 * theta * ((-1 * d_u[i]) ** beta)*pi2
            # 获得每个点对应前景价值
    prospect_v = [0 for i in range(k)]  # 取中间值为参考点
    d_v = [0 for i in range(k)]
    for i in range(k):
        d_v[i] = point_v[i] - average
        if (d_v[i] >= 0):
            prospect_v[i] = 1 * (d_v[i] ** alpha) * pi1
        if (d_v[i] < 0):
            prospect_v[i] = -1 * ((-1 * d_v[i]) ** beta) * theta * pi2
    prospect_pi = [0 for i in range(k)]  # 取中间值为参考点
    d_pi = [0 for i in range(k)]
    for i in range(k):
        d_pi[i] = point_pi[i] - average
        if (isinstance(point_pi[i], complex)):
            print('复数',point_pi[i],a,b,c,d,e,f,q)
        if (d_pi[i] >= 0):
            prospect_pi[i] = (d_pi[i] ** alpha) * pi1
        if (d_pi[i] < 0):
            prospect_pi[i] = -1 * theta * ((-1 *d_pi[i]) ** beta) * pi2
    weight_u = []
    minum =-1*theta*((0.5)**beta)*pi2
    p_u = [0 for i in range(k)]
    for i in range(k):
        p_u[i] = prospect_u[i] - minum
    for i in range(k):
        sum1 = sum(p_u)
        if (sum1 == 0):
            weight_u.append(1 / k)
        else:
            weight_u.append(p_u[i] / sum1)
    weight_v = []
    p_v = [0 for i in range(k)]
    for i in range(k):
        p_v[i] = prospect_v[i] - minum
    for i in range(k):
        sum4 = sum(p_v)
        if (sum4 == 0):
            weight_v.append(1 / k)
        else:
            weight_v.append(p_v[i] / sum(p_v))
    weight_pi = []
    p_pi = [0 for i in range(k)]
    for i in range(k):
        p_pi[i] = prospect_pi[i] - minum
    for i in range(k):
        sum4 = sum(p_pi)
        if (sum4 == 0):
            weight_pi.append(1 / k)
        else:
            weight_pi.append(p_pi[i] / sum(p_pi))
    value_u = []
    value_v = []
    value_pi = []
    for i in range(k):
        value_u.append(weight_u[i] * point_u[i])
        value_v.append(weight_v[i] * point_v[i])
        value_pi.append(weight_pi[i] * point_pi[i])
    u=sum(value_u)
    v=sum(value_v)
    pi=sum(value_pi)
    # score11 = m.log((m.exp(2 * (u - v)) / ((1 - (a + b + c + d) / 2 + u + v))) ** 0.5, np.exp(1))
    # score =(m.exp(2*((u-v)+u*(1-u-v)))/(1+(1-u-v)))**(1/2)
    score12 = m.log((m.exp(2 * (u - v)) / ((1 + 0.5 * (a + b + c + d)) / 2)) ** 0.5, np.exp(1))
    # score=(u-v+1)/((1 + 0.5 * (a + b + c + d)) / 2)
    # score = (m.exp(2 * (u - v) ) / (1 + pi)) ** 0.5
    score=m.log((m.exp(2 * (u - v)) / (1 + pi)) ** 0.5, np.exp(1))
    # if (isinstance(score, complex)):
    #     print(11111, u, v, pi,score,a,b,c,d,e,f)
    return score12
def getpoint1(IVq_ROF, q):
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    # score = (m.exp(2 * (a- c+a*(1-a-c))) / (1 + 1 - a - c)) ** (1 / 2)
    score=(m.exp(2 * (a-c))/ (1 + a + c)) ** (1 / 2)
    return score
def sc(IVq_ROF, q):
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    score= (m.log(a + b + c + d + 1)+ 2*(a - c + b - d)+((b - a) + (d - c)) +(c + b - a - d)-np.sign(a+b+c+d) * (m.log(3)))/4
    return score
def GMscore(IVq_ROF,q):
    '''
    公式3.6Sgm
    :param a:
    :param b:
    :param c:
    :param d:
    :param q:
    :return:
    '''
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    q=1
    A = a ** q
    B = b ** q
    C = c ** q
    D = d ** q
    if(A+B+C+D==0):
        score=0
    else:
        score=(A+B-C-D)/2+(A+B+2*(A*B-C*D))/(A+B+C+D)
    return score
def mytest(IVq_ROF,q):
    '''
    52、yqp的得分函数
    :param IVq_ROF:
    :param q:
    :return:
    '''
    # 现在假设，我们有1000个点
    # 第一步：给出两个区间(u1,u2)(v1,v2) 和 （u1,u2)(v1,v2)
    # 我的思路，就是每个权重/总的权重(e),这样相加为1，再乘上beta分布，越靠近区间中间beta函数值越大
    a = IVq_ROF[0][0]
    b = IVq_ROF[0][1]
    c = IVq_ROF[1][0]
    d = IVq_ROF[1][1]
    pai1 = (1 - a ** q - c ** q) ** (1 / q)
    pai2 = (1 - b ** q - d ** q) ** (1 / q)
    SF_g = (a-c+b-d)/2+1
    score2 = get_score(a,b)
    score3 = get_score(b,1-d)
    score4 = get_score(c,d)
    score = SF_g+score2+score3+score4
    return score


factorial = [1]  # 1/n!
# 初始化阶乘
def fac():
    global factorial
    for i in range(1,21):
        temp = 1
        for j in range(1, i + 1):
            temp *= j
        factorial.append(temp)
    # n！= √2πn*(n/e)**n
    for i in range(21,101):
        tem = int(math.sqrt(2*math.pi*i)*((i/math.e)**i))
        factorial.append(tem)

def get_e(times):
    sum = 1
    # 求和1/n!
    for i in range(1, times+1):
        temp = factorial[i]
        sum += 1 / temp
    return sum

def get_alpha_beta(left,right):
    avg = (right-left)/2
    avg = round(avg,2)
    alpha = avg*100
    beta = 100-alpha
    alpha = alpha*3
    beta = beta*3
    return alpha,beta

def get_score(left,right):
    score = 0

    if left == right:
        return left
    else:
        aerfa,beita = get_alpha_beta(left,right)
        spacing = (right-left)/100
        x = np.arange(left, right, spacing)  # 给定的输入数据 [0.0-1]
        for i in range(100):
            score += get_e(i) / math.e * beta.pdf(x, aerfa, beita)[i]
        return score

def E_T(L1,L2):
    '''
    test7中用到的定义函数
    :param L1: 左边界
    :param L2: 右边界
    :return:
    '''

    beta = 0.9
    ans = L1 + (L2 - L1) *beta
    return ans


def score_exactvalue2(i, q):
    '''

    :param i:广义正交数
    :prem q:
    :return: 得分,精确值
    '''
    score = 1 / 2 * (i[0][0] ** q + i[0][1] ** q - i[1][0] ** q - i[1][1] ** q)  # 得分函数
    exact_value = 1 / 2 * (i[0][0] ** q + i[0][1] ** q + i[1][0] ** q + i[1][1] ** q)  # 精确值函数
    return score, exact_value

def scan_q(case):
    q = 1
    length = len(case)

    for i in case:
        for k in i:
            if k[0][0] == 0:
                k[0][0] = k[0][0] + 0.00001
            if k[1][0] == 0:
                k[1][0] = k[0][0] + 0.0001
            if k[0][1] == 0:
                k[0][1] = k[0][0] + 0.01
            if k[1][1] == 0:
                k[1][1] = k[0][0] + 0.01
            count = 0
            while (k[0][0] ** q + k[1][0] ** q >= 1 or k[0][1] ** q + k[1][1] ** q >= 1):
                q += 1
                if count < 20:
                    count = count + 1
                else:
                    break
    return q


'''if __name__ == "__main__":

    # print(case2)
    # 第一个案例,L1=L2=L3=L4=0,隶属度和非隶属度不是区间值的，即广义正交模糊数
    case3 = getZeroRandomIVq_ROF()
    # print(case3)
    # 第二个案例，L1=L2=L3=L4且不等于0，其中a2从左往右移动
    case4 = getequalallnozerorcase()
    # print(case4)
    # 第3个测试案例，L1=L3, L2=L4 且都不等于0
    case5 = getL1eqL3L2eqL4case()
    # print(case5)
    # 第4个案例,L1=L3，L2=L4且不等于0，其中a2从左往右移动
    case6 = getL1eqL3L2noeqL4case()
    # print(case6)
    # 第5个案例,L1>L3, L2=L4,S1=S2且不等于0，其中a2从左往右移动
    case7 = getL1bigerL3L2eqL4case()
    # print(case7);;
    # 第6个案例,L1>L3，L2>L4且不等于0，其中a2从左往右移动
    case8 = getL1bigerL3L2bigerL4case()
    # print(case7)
    # 第7个案例,L1>L3，L2>L4且不等于0，其中a2从左往右移动
    case9 = getL1bigerL3L2litterL4case()
    # print(case8)
    # 案例8，论文中的数据
    case10 = li_data()
    # 案例9  随机生产测试数据
    case11 = RandomCase()

    case12 = getstopRandomCase()

    case13 = getStopEndRandomCase()

    case14 = getL1eqlL2L3eqL4Case()

    case15 = getL1eqlL2L3eqL4Case_1()

    case16 = getL1randomL2L3eqL4Case()
    # print(f6([[0.7601, 0.7601], [0.7601, 0.7601]],5))
    # print(f6([[0.7101, 0.7101], [0.7101, 0.7101]],5))
    # print(scan_q([[[0.6782, 0.6782], [0.6782, 0.6782]], [[0.8782, 0.8782], [0.8782, 0.8782]]]))

    data_list = [case3[0:41], case4[0:41], case5[0:41]
       , case6[0:41], case7[0:41], case8[0:41], case9[0:41], case12[0:300], case13[0:400]]

    data_list2=[case3[0:41],case12[0:300],case13[0:400]]

    data_list3 = [case14[0:1001]]

    data_list4 = [case15[0:1001]]

    title_list = ['getZeroRandomIVq_ROF', 'getequalallnozerorcase',
                  'getL1eqL3L2eqL4case', 'getL1eqL3L2noeqL4case',
                  'getL1bigerL3L2eqL4case', 'getL1bigerL3L2bigerL4case',
                  'getL1bigerL3L2litterL4case', 'getstopRandomCase', 'getStopEndRandomCase','getL1eqlL2L3eqL4Case']

    title_list2 = ['getZeroRandomIVq_ROF', 'getstopRandomCase', 'getStopEndRandomCase']

    # 情况一
    for k in range(len(data_list)):
        list1 = []
        list2 = []
        q = scan_q(data_list[k])
        # q=3
        print('q的取值为：', q)
        print(data_list)
        for i in data_list[k]:
            # socre1 = f7(i[0], q)
            # socre2 = f7(i[1], q)
            socre1 = getpoint(i[0], q)
            socre2 = getpoint(i[1], q)
            list1.append(socre1)
            list2.append(socre2)
        show_2D([list1, list2], ['contrast', 'Me'], title_list[k], title_list[k])


    # 情况二
    # for k in range(len(data_list2)):
    #     list1 = [];
    #     list2 = []
    #     q = scan_q(data_list2[k])
    #     # q=3
    #     print('q的取值为：', q)
    #     print(data_list2)
    #     for i in data_list2[k]:
    #         # socre1 = f7(i[0], q)
    #         # socre2 = f7(i[1], q)
    #         socre1 = test23(i[0], q)
    #         socre2 = test23(i[1], q)
    #         list1.append(socre1)
    #         list2.append(socre2)
    #     show_2D([list1, list2], ['contrast', 'Me'], title_list2[k], title_list2[k])

    # random_alpha = get_Beta_random_number(loc=2/3, scale=2/3, N=100000)
    # random_beta = get_Beta_random_number(loc=2/3, scale=2/3, N=100000)

    counts = 0
    fail_num = 0
    flag = 1
    random_data = [case5,case6,case7,case8,case9,case10, case11]
    fac()
    # random_data = [case11]
    # random_data = [case3,case12,case13]
    # random_data = [case15]
    temp = 0
    for k in random_data:
        for i in k:
            # 特殊情况专用（出现UA，UB）：test28,test23,test51
            # score = test28(i,q)
            # if(score==0):
            #     flag = 0
            #     fail_num+=1
            #     print(i, '数据无法比较')

            # alpha,beta情况用这个 : test8
            # alpha1 = random_alpha[temp]
            # beta1 = random_beta[temp]
            # temp+=1
            # socre1 = test8(i[0], q,alpha1,beta1)
            # socre2 = test8(i[1], q,alpha1,beta1)
            # if socre1 == socre2:
            #     flag = 0
            #     fail_num += 1
            #     # print(i, '数据无法比较')
            #     print(i, alpha1,beta1,'数据无法比较')

            # 一般情况用这个
            socre1 = getpoint(i[0],q)
            socre2 = getpoint(i[1],q)
            # counts+=1
            # print("已监测完第",counts,'条')
            if socre1 == socre2:
                flag = 0
                fail_num += 1
                print(i, '数据无法比较')

    # while (flag == 1 and times<10):
    #     case16 = getL1randomL2L3eqL4Case()
    #     random_data = [case16]
    #     for k in random_data:
    #         for i in k:
    #             socre1 = test27(i[0], q)
    #             socre2 = test27(i[1], q)
    #             if socre1 == socre2:
    #                 flag = 0
    #                 fail_num += 1
    #                 print(i, '数据无法比较')
    #     print('已运行第',times,'次')
    #     times+=1

    if flag:
        print('Li_data与random_data数据测试通过')
    print('失败的数据项有',fail_num,'条')'''